class Indexs < ActiveRecord::Migration
  def change
    add_index :articles, :user_id
    add_index :articles, :category_id

    add_index :article_contents, :article_id
    add_index :article_previews, :article_id

    add_index :users, :email, unique: true


    add_index :articles, :slug, unique: true, where: 'slug != NULL'
    add_index :categories, :slug, unique: true, where: 'slug != NULL'
    add_index :articles, :published_at, where: 'published_at != NULL'
    add_index :articles, [:published_at, :slug], where: 'slug != NULL AND published_at != NULL'
  end
end
